var api = require('../../utils/api.js');

var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        id:'',
        list:[1,2,3],
        listData:[1,2,3,4],
        lists:[]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({
            id:options.id
        })

        var that=this;
        api.post({
            url: 'cases/getxumulistbyid',
            data: {id:options.id},
            success: data => {
                that.setData({
                    lists:data.data
                })
            }
        })

    },

    setselect(ret){
        console.log(ret);
        var index=ret.currentTarget.dataset.index;
        var lists=this.data.lists;
        lists[index].select=lists[index].select==1?'0':'1';
        this.setData({
            lists:lists
        })
    },

    printinfo(ret){
        var id=ret.currentTarget.dataset.id;
        this.printvideo(id);
    },


    printinfos(){
        var list=this.data.lists;
        var that=this;
        list.forEach(function(item){
            if(item.select==1){
                console.log(item.id);

                that.printvideo(item.id);
            }
        })
    },
    // 全选
    quanxuan(){
        var lists=this.data.lists;
        var i=lists[0].select;
        lists.forEach(function(item){
            item.select=i==1?'0':'1';
        })
        this.setData({
            lists:lists
        })
    },

    printvideo(id){
        wx.showLoading({
          title: '提交中...'
        })
        api.post({
            url: 'printr/printinfobyid',
            data: {id:id},
            success: data => {
                wx.hideLoading();
                wx.showToast({
                  title: data.msg,
                  icon:'none'
                })
            }
        })

    },
    bianji(ret){
        var id=ret.currentTarget.dataset.id;
        wx.navigateTo({
          url: '/pages/list/edits?id='+id
        })
    },
    add(ret){
        var id=this.data.id;
        wx.navigateTo({
          url: '/pages/list/add?caseid='+id
        })
    },
    seeinfobycode(ret){
        console.log(ret);
        var code=ret.currentTarget.dataset.id;
      
        wx.navigateTo({
          url: '/pages/about/update?code='+code,
        })

    }



})